console.log('我是login');
$(function(){
	var screenH=window.screen.height;
	var layout=$('#layout');
	layout.height(screenH);
})
//密码的显示与隐藏
$(function(){
	var $selector = $('#switch');
	$selector.off('tap').on('tap',function(){
		var $this=$(this);
		$this.hasClass('bg-hide')?$this.addClass('bg-show').removeClass('bg-hide').prev('input').attr({'type':'text'}):$this.addClass('bg-hide').removeClass('bg-show').prev('input').attr({'type':'password'})
	})
	
})

$(function(){
	var sendData={};
	var lpHost=common.lpHost;
	var loginPort=common.loginPort;
	var url=lpHost+loginPort;
	baseInfoForm.submit.off('tap').on('tap',function(e){
		var $this=$(this);
	    var checkCase=$this.hasClass("act-ago");
	    var resultPassword=baseInfoForm.testPassword({targetSelector:baseInfoForm.password,noticeMsg:"密码"});
	    var testText=baseInfoForm.testText({targetSelector:baseInfoForm.tel,noticeMsg:"账号",length:15});
	    sendData=common.getSendDataByForm(baseInfoForm.form);
    	if(!!checkCase&&!!resultPassword&&!!testText){
    		callAjax(url,sendData);
    	}else{
    		console.log("不准发送ajax请求");
    	}
    	e.preventDefault();
    	return false;
	});	
});
function actedStyle () {
    baseInfoForm.submit.removeClass("act-ago").addClass("acted-yet");
}
function actAgoStyle () {
    baseInfoForm.submit.removeClass("acted-yet").addClass("act-ago");
}
function callAjax(url,sendData){
	baseInfoForm.formPost({
		url:url,
		sendData:sendData,
		resSuccess:function(data){
			var data=data['res']['data'];
				actedStyle();
				baseInfoForm.form[0].reset();
				//设置cookie和token；
				common.setCookie("loginSuccess","loginSuccess",1);//1代表一个小时
				common.setLocalStorage('houseSearchAgentInfoToken',JSON.stringify(data.token));
				window.location.href="index.html";	
		},
		resFailed:function(data){
			baseInfoForm.changeMsg('请联系管理员');
			actAgoStyle();
		}
	});
}